/**
 * 
 */
package jmath.function.utils;

import java.util.*;
import jmath.function.*;

/**
 * @author timon
 * 
 */
public class Timer extends IOFunction {
	private Date date;

	public void tic() {
		date = new Date();
	}

	public void toc() {
		if (date != null) {
			jMathConsole.writeln((new Date().getTime() - date.getTime())
					+ ioUtils.getMessage("MILLISECS"));
		} else {
			jMathConsole.writeln(ioUtils.getMessage("TIMER_NOT_INSTALLED"));
		}
	}

	public void stop(long millisecs) {
		try {
			Thread.sleep(millisecs);
		} catch (Exception ignored) {
		}
	}
	
	public void fullStop() {
		throw new RuntimeException();
	}
}
